local base = piece "base"
local head = piece "head"
local wheel = piece "wheel"

local function Initialize ()
	Signal(1)
	SetSignalMask(2)

        Spin(wheel, y_axis, 3, 0.1)

        while ( true ) do
                Move(head, y_axis, 10, 2)
                WaitForMove(head, y_axis)
                Sleep(100)
                Move(head, y_axis, 0, 2)
                WaitForMove(head, y_axis)
        end    
end

local function Deinitialize ()
	Signal(2)
	SetSignalMask(1)

	Move(head, y_axis, 0, 2)
	StopSpin(wheel, y_axis, 0.1)
end

function script.Activate ( )
	StartThread(Initialize)
end

function script.Deactivate ( )
	StartThread(Deinitialize)
end
